package com.lancoo.ccas53.controller;

import cn.hutool.core.bean.BeanUtil;
import com.lancoo.ccas53.arrangecourse.ArrangeCourseService;
import com.lancoo.ccas53.aspect.LogAnnotation;
import com.lancoo.ccas53.aspect.UpdateScheduleLimiter;
import com.lancoo.ccas53.entity.RuleUsable;
import com.lancoo.ccas53.entity.Schedule;
import com.lancoo.ccas53.entity.TeachingClassWeek;
import com.lancoo.ccas53.pojo.common.PageInfo;
import com.lancoo.ccas53.pojo.constant.ScheduleState;
import com.lancoo.ccas53.pojo.dto.*;
import com.lancoo.ccas53.pojo.vo.*;
import com.lancoo.ccas53.service.*;
import com.lancoo.ccas53.service.impl.TimeSlotCheckService;
import com.lancoo.ccas53.util.ResponseObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

/**
 * @Author: liufeng
 * @CreateTime: 2024-06-17  09:33
 * @Description:
 */

@Api(tags = "编排课表")
@RestController
@RequestMapping("/arrange")
public class CourseArrangeController {


    @Resource
    private ScheduleService scheduleService;
    @Resource
    private TeacherService teacherService;
    @Resource
    private RoomService roomService;
    @Resource
    private RuleUsableService ruleUsableService;
    @Resource
    private ArrangeCourseService arrangeCourseService;
    @Resource
    private TeachingClassWeekService teachingClassWeekService;
    @Resource
    private TeachingClassService teachingClassService;
    @Resource
    private TimeSlotCheckService timeSlotCheckService;

    @ApiOperation("生成教学班课表初始数据")
    @PostMapping(value = "/allToTeachingClassUnit")
    @LogAnnotation(operationType = "1", operationContent = "生成教学班课表初始数据")
    public ResponseObject<Boolean> allToTeachingClassUnit(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                          @ApiParam(value = "院系id", required = false) @RequestHeader(required = false) String baseCollegeId) {
        return ResponseObject.ofSuccess(scheduleService.allToTeachingClassUnit(taskId,baseCollegeId));
    }

    @ApiOperation("教室课时检测")
    @GetMapping(value = "/roomCheck")
    public ResponseObject<Object> roomCheck(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                            @ApiParam(value = "学校Id", required = true) @RequestParam String schoolId,
                                            @ApiParam(value = "学期", required = true) @RequestParam String term,
                                            @ApiParam(value = "院系id", required = false) @RequestParam(required = false) Integer collegeId) {

//        return timeSlotCheckService.roomCheck(taskId, schoolId, term, collegeId);
        return ResponseObject.ofSuccess(new ArrayList<>());
    }

    @ApiOperation("自动排课")
    @GetMapping(value = "/autoArrangement")
    public ResponseObject<Object> courseArrangement(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                    @ApiParam(value = "院系id", required = false) @RequestHeader(required = false) String baseCollegeId,
                                                    @ApiParam(value = "专业性质，1:公共课，2:专业课", required = false) @RequestParam(required = false) Integer majorProp) {
//        //fix bug 修复自动排课时，前端全校排课时，传入的collegeId不为null
//        collegeId = majorProp == null ? null : collegeId;
        return ResponseObject.ofSuccess(scheduleService.autoArrangement(taskId, baseCollegeId, majorProp));
    }


    @ApiOperation("同步更新")
    @PostMapping(value = "/synchronize")
    @LogAnnotation(operationType = "4", operationContent = "同步更新")
    public ResponseObject<Object> synchronizeUpdate(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId) {
        scheduleService.synchronizeUpdate(taskId);
        return ResponseObject.ofSuccess();
    }

    @ApiOperation("是否锁定所有正常教学班")
    @GetMapping(value = "/isLockedNormal")
    @LogAnnotation(operationType = "3", operationContent = "查看是否锁定所有正常教学班")
    public ResponseObject<Integer> isLockedNormal(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                  @ApiParam(value = "学院", required = false) @RequestHeader(required = false) String baseCollegeId) {
        return ResponseObject.ofSuccess(scheduleService.isLockedNormal(taskId, baseCollegeId));
    }

    @ApiOperation("锁定所有正常教学班")
    @PostMapping(value = "/lockNormal")
    @LogAnnotation(operationType = "2", operationContent = "锁定所有正常教学班")
    public ResponseObject<Object> lockedNormal(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                               @ApiParam(value = "学院", required = false) @RequestHeader(required = false) String baseCollegeId,
                                               @ApiParam(value = "1：解锁 2：锁", required = true) @RequestParam Integer lock) {
        scheduleService.allNormalLocal(taskId, baseCollegeId, lock);
        return ResponseObject.ofSuccess();
    }


    @ApiOperation("获取调整场地节次 列表")
    @PostMapping(value = "/getVenueSession")
    @LogAnnotation(operationType = "3", operationContent = "获取调整场地节次列表")
    public ResponseObject<PageInfo<VenueSessionVo>> getVenueSession(@ApiParam(value = "页码", required = true) @RequestParam Integer currentPage,
                                                                    @ApiParam(value = "页容", required = true) @RequestParam Integer pageSize,
                                                                    @ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                    @ApiParam(value = "调整周次 1表示待调整周次", example = "101010101", required = false) @RequestParam(required = false) String weeks,
                                                                    @ApiParam(value = "节次课时编码，多节次逗号分割", example = "0102,0103", required = false) @RequestParam(required = false) String timeCodes,
                                                                    @ApiParam(value = "校区id", required = false) @RequestParam(required = false) Integer campusId,
                                                                    @ApiParam(value = "楼宇id", required = false) @RequestParam(required = false) Integer buildingId,
                                                                    @ApiParam(value = "场地类型", required = false) @RequestParam(required = false) Integer selectRoomType,
                                                                    @ApiParam(value = "教室id", required = false) @RequestParam(required = false) Long roomId,
                                                                    @ApiParam(value = "搜索关键词", required = false) @RequestParam(required = false) String keyword,
                                                                    @ApiParam(value = "教学班相关信息", required = true) @RequestBody VenueSessionInput venueSessionInput,
                                                                    @ApiParam(value = "是否抛异常", required = true) @RequestParam Integer departId,
                                                                    @ApiParam(value = "忽略场地冲突 0 关闭 1 开启", required = false) @RequestParam Integer conflictCheck,
                                                                    @ApiParam(value = "忽略场地容量 0 关闭 1 开启", required = false) @RequestParam Integer capacityCheck,
                                                                    @ApiParam(value = "学院id", required = false) @RequestParam(required = false) String collegeId,
                                                                    @ApiParam(value = "变绿 外面:0 里面:1", required = true) @RequestParam int outer
    ) {
        Integer optionType = ruleUsableService.lambdaQuery().eq(RuleUsable::getTaskId, taskId)
                .eq(RuleUsable::getCode, 1).one().getOptionType();
        //全校统一排课 校区id置为null获取全部
        if (optionType == 2 || optionType == 3) {
            venueSessionInput.setCampusId(null);
        }
        weeks = venueSessionInput.getWeek();
        venueSessionInput.setStudentNumber(venueSessionInput.getClassNum());
        ArrangeTeachingClassDto teachingClass = BeanUtil.copyProperties(venueSessionInput, ArrangeTeachingClassDto.class);
        teachingClass.setProhibitTimeslotCodes("");

        return ResponseObject.ofSuccess(scheduleService.getVenueSession(currentPage, pageSize, taskId, weeks, timeCodes, campusId, buildingId, selectRoomType, roomId, keyword, teachingClass, departId, conflictCheck, capacityCheck, collegeId, outer));
    }

    @ApiOperation("获取分组调整场地节次列表")
    @PostMapping(value = "/getGroupVenueSession")
    @LogAnnotation(operationType = "3", operationContent = "获取分组调整场地节次列表")
    public ResponseObject<HashSet<String>> getGroupVenueSession(@ApiParam(value = "页码", required = true) @RequestParam Integer currentPage,
                                                                @ApiParam(value = "页容", required = true) @RequestParam Integer pageSize,
                                                                @ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                @ApiParam(value = "调整周次 1表示待调整周次", example = "101010101", required = false) @RequestParam(required = false) String weeks,
                                                                @ApiParam(value = "节次课时编码，多节次逗号分割", example = "0102,0103", required = false) @RequestParam(required = false) String timeCodes,
                                                                @ApiParam(value = "校区id", required = false) @RequestParam(required = false) Integer campusId,
                                                                @ApiParam(value = "楼宇id", required = false) @RequestParam(required = false) Integer buildingId,
                                                                @ApiParam(value = "教室id", required = false) @RequestParam(required = false) Long roomId,
                                                                @ApiParam(value = "搜索关键词", required = false) @RequestParam(required = false) String keyword,
                                                                @ApiParam(value = "教学班相关信息", required = true) @RequestBody List<VenueSessionInput> venueSessionInputs,
                                                                @ApiParam(value = "单位id", required = false) @RequestParam(required = false) Integer departId,
                                                                @ApiParam(value = "忽略场地冲突 0 关闭 1 开启", required = true) @RequestParam Integer conflictCheck,
                                                                @ApiParam(value = "忽略场地容量 0 关闭 1 开启", required = true) @RequestParam Integer capacityCheck,
                                                                @ApiParam(value = "学院id", required = true) @RequestParam String collegeId
    ) {
        Integer optionType = ruleUsableService.lambdaQuery().eq(RuleUsable::getTaskId, taskId)
                .eq(RuleUsable::getCode, 1).one().getOptionType();
        //全校统一排课 校区id置为null获取全部
        if (optionType == 2 || optionType == 3) {
            venueSessionInputs.forEach(venueSessionInput -> venueSessionInput.setCampusId(null));
        }
        weeks = venueSessionInputs.get(0).getWeek();
        venueSessionInputs.forEach(venueSessionInput -> venueSessionInput.setStudentNumber(venueSessionInput.getClassNum()));
        List<ArrangeTeachingClassDto> teachingClassList = BeanUtil.copyToList(venueSessionInputs, ArrangeTeachingClassDto.class);
        teachingClassList.forEach(teachingClass -> teachingClass.setProhibitTimeslotCodes(""));
        return ResponseObject.ofSuccess(scheduleService.getGroupVenueSession(currentPage, pageSize, taskId, weeks, timeCodes, campusId, buildingId, roomId, keyword, teachingClassList, departId, 1, 0, collegeId));
    }

    @ApiOperation("更新场地节次")
    @UpdateScheduleLimiter(qps = 0.25)
    @Transactional(rollbackFor = Exception.class)
    @PostMapping(value = "/updateVenueSession")
    @LogAnnotation(operationType = "2", operationContent = "更新场地节次")
    public ResponseObject<List<ScheduleDto>> updateVenueSession(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                @ApiParam(value = "学校Id", required = true) @RequestParam String schoolId,
                                                                @ApiParam(value = "学期", required = true) @RequestParam String term,
                                                                @ApiParam(value = "调整至课表", required = true) @RequestBody UpdateVenueSessionInput updateVenueSessionInput,
                                                                @ApiParam(value = "是否分组", required = false) @RequestParam(required = false) Boolean group) {
        List<ScheduleDto> scheduleDtos = scheduleService.updateVenueSession(updateVenueSessionInput.getStartSchedule(), updateVenueSessionInput.getStopSchedule(),
                updateVenueSessionInput.getTeachingClassId(), updateVenueSessionInput.getHourType());
        //更新冲突表 排课状态
        arrangeCourseService.manualAdjustmentUpdate(schoolId, term, taskId, null, updateVenueSessionInput.getTeachingClassId());
        return ResponseObject.ofSuccess(scheduleDtos);
    }

    @ApiOperation("选课模块生成教学班课表初始数据")
    @PostMapping(value = "/generateTeachingClassUnitSelect")
    @LogAnnotation(operationType = "1", operationContent = "生成教学班课表初始数据")
    public ResponseObject<List<ScheduleSelectGroup>> generateTeachingClassUnitSelect(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                                     @ApiParam(value = "调整课表", required = true) @RequestBody GenerateTeachingClassUnitInputSelect generateTeachingClassUnit) {
        return ResponseObject.ofSuccess(scheduleService.generateTeachingClassUnitSelect(taskId, generateTeachingClassUnit));
    }

    @ApiOperation("选课模块删除教学班课表数据")
    @PostMapping(value = "/removeTeachingClassScheduleSelect")
    @LogAnnotation(operationType = "1", operationContent = "生成教学班课表初始数据")
    public ResponseObject<Object> removeTeachingClassScheduleSelect(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                    @ApiParam(value = "教学班ids", required = true) @RequestBody List<String> teachingClassIds) {
        scheduleService.removeTeachingClassScheduleSelect(taskId, teachingClassIds);
        return ResponseObject.ofSuccess();
    }

    @ApiOperation("选课模块获取调整场地节次列表")
    @PostMapping(value = "/getVenueSessionSelect")
    @LogAnnotation(operationType = "3", operationContent = "选课模块获取调整场地节次列表")
    public ResponseObject<PageInfo<VenueSessionVo>> getVenueSessionSelect(@ApiParam(value = "页码", required = true) @RequestParam Integer currentPage,
                                                                          @ApiParam(value = "页容", required = true) @RequestParam Integer pageSize,
                                                                          @ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                          @ApiParam(value = "调整周次 1表示待调整周次", example = "101010101", required = false) @RequestParam(required = false) String weeks,
                                                                          @ApiParam(value = "节次课时编码，多节次逗号分割", example = "0102,0103", required = false) @RequestParam(required = false) String timeCodes,
                                                                          @ApiParam(value = "校区id", required = false) @RequestParam(required = false) Integer campusId,
                                                                          @ApiParam(value = "楼宇id", required = false) @RequestParam(required = false) Integer buildingId,
                                                                          @ApiParam(value = "教室id", required = false) @RequestParam(required = false) Long roomId,
                                                                          @ApiParam(value = "搜索关键词", required = false) @RequestParam(required = false) String keyword,
                                                                          @ApiParam(value = "教学班相关信息", required = true) @RequestBody VenueSessionInputSelect venueSessionInput,
                                                                          @ApiParam(value = "是否抛异常", required = true) @RequestParam Integer departId,
                                                                          @ApiParam(value = "忽略场地冲突 0 关闭 1 开启", required = false) @RequestParam Integer conflictCheck,
                                                                          @ApiParam(value = "忽略场地容量 0 关闭 1 开启", required = false) @RequestParam Integer capacityCheck,
                                                                          @ApiParam(value = "学院id", required = false) @RequestParam(required = false) String collegeId
    ) {
        Integer optionType = ruleUsableService.lambdaQuery().eq(RuleUsable::getTaskId, taskId)
                .eq(RuleUsable::getCode, 1).one().getOptionType();
        //全校统一排课 校区id置为null获取全部
        if (optionType == 2 || optionType == 3) {
            venueSessionInput.setCampusId(null);
        }
        weeks = venueSessionInput.getWeek();
        ArrangeTeachingClassDto teachingClass = BeanUtil.copyProperties(venueSessionInput, ArrangeTeachingClassDto.class);
        teachingClass.setProhibitTimeslotCodes("");

        return ResponseObject.ofSuccess(scheduleService.getVenueSessionSelect(currentPage, pageSize, taskId, weeks, timeCodes, campusId, buildingId, roomId, keyword, teachingClass, departId, conflictCheck, capacityCheck, collegeId));
    }

    @ApiOperation("选课模块更新场地节次")
    @UpdateScheduleLimiter(qps = 0.25)
    @Transactional(rollbackFor = Exception.class)
    @PostMapping(value = "/updateVenueSessionSelect")
    @LogAnnotation(operationType = "2", operationContent = "更新场地节次")
    public ResponseObject<List<ScheduleSelectGroup>> updateVenueSessionSelect(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                              @ApiParam(value = "学校Id", required = true) @RequestParam String schoolId,
                                                                              @ApiParam(value = "学期", required = true) @RequestParam String term,
                                                                              @ApiParam(value = "调整至课表", required = true) @RequestBody UpdateVenueSessionInputSelect updateVenueSessionInput) {
        return ResponseObject.ofSuccess(scheduleService.updateVenueSessionSelect(updateVenueSessionInput.getStartSchedule(), updateVenueSessionInput.getStopSchedule(),
                updateVenueSessionInput.getTeachingClassId(), updateVenueSessionInput.getHourType()));
    }


    @ApiOperation("删除课表安排")
    @Transactional(rollbackFor = Exception.class)
    @PostMapping(value = "/removeSchedule")
    @LogAnnotation(operationType = "4", operationContent = "删除课表安排")
    public ResponseObject<Boolean> removeSchedule(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                  @ApiParam(value = "学校Id", required = true) @RequestParam String schoolId,
                                                  @ApiParam(value = "学期", required = true) @RequestParam String term,
                                                  @ApiParam(value = "课表", required = true) @RequestBody List<Schedule> scheduleList) {
//        List<Long> tcIds = scheduleList.stream().map(Schedule::getTeachingClassId).distinct().collect(Collectors.toList());
//        List<TeachingClass> list = teachingClassService.lambdaQuery().in(TeachingClass::getTeachingClassId, tcIds).list();
//        List<Long> courseIds = list.stream().map(TeachingClass::getCourseId).distinct().collect(Collectors.toList());
//        if (courseIds.contains(2003491L) || courseIds.contains(2003547L)){
//            throw new BizException("合班课程不能删除");
//        }
        scheduleService.removeSchedule(taskId, scheduleList);

        //更新冲突表 排课状态
        arrangeCourseService.manualAdjustmentUpdate(schoolId, term, taskId, null, scheduleList.get(0).getTeachingClassId());

        teachingClassWeekService.lambdaUpdate()
                .eq(TeachingClassWeek::getTeachingClassId, scheduleList.get(0).getTeachingClassId())
                .eq(TeachingClassWeek::getHourType, scheduleList.get(0).getHourType())
                .set(TeachingClassWeek::getScheduleState, ScheduleState.UNARRANGE.getCode())
                .set(TeachingClassWeek::getIsLocked, 1)
                .update();

        return ResponseObject.ofSuccess(true);
    }

    @ApiOperation("我的教学班树")
    @GetMapping(value = "/teachingClassTree/owner")
    @LogAnnotation(operationType = "3", operationContent = "我的教学班树")
    public ResponseObject<OwnerTeachingClassTree> teachingClassTreeOwner(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                         @ApiParam(value = "baseCollegeId", required = false) @RequestParam(required = false) String baseCollegeId,
                                                                         @ApiParam(value = "关键字", required = false) @RequestParam(required = false) String keyword) {
        return ResponseObject.ofSuccess(scheduleService.teachingClassTreeOwner(taskId, baseCollegeId, keyword));
    }

    @ApiOperation("全校教学班树")
    @GetMapping(value = "/teachingClassTree/school")
    @LogAnnotation(operationType = "3", operationContent = "全校教学班树")
    public ResponseObject<List<CollegeTeachingClassTree>> teachingClassTreeSchool(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                                  @ApiParam(value = "关键字", required = false) @RequestParam(required = false) String keyword) {
        return ResponseObject.ofSuccess(scheduleService.teachingClassTreeSchool(taskId, keyword));
    }

    @ApiOperation("获取教学班课表")
    @PostMapping(value = "/getTeachingClassAndSchedule")
    @LogAnnotation(operationType = "3", operationContent = "获取教学班课表")
    public ResponseObject<List<TeachingClassWeekScheduleDto>> getTeachingClassAndSchedule(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                                          @ApiParam(value = "教学班ids", required = true) @RequestBody List<Long> teachingClassIds) {
        return ResponseObject.ofSuccess(scheduleService.getTeachingClassSchedule(taskId, teachingClassIds));
    }

    @ApiOperation("获取教学班课表")
    @PostMapping(value = "/getTeachingClassScheduleWeek")
    @LogAnnotation(operationType = "3", operationContent = "获取教学班课表")
    public ResponseObject<String> getTeachingClassAndScheduleByType(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                    @ApiParam(value = "教学班ids", required = true) @RequestParam Long teachingClassId,
                                                                    @ApiParam(value = "type", required = true) @RequestParam Integer hourType,
                                                                    @ApiParam(value = "preGroup", required = true) @RequestParam String preGroup) {
        return ResponseObject.ofSuccess(scheduleService.getTeachingClassAndScheduleByType(taskId, teachingClassId, hourType, preGroup));
    }

    @ApiOperation("获取分组教学班课表")
    @GetMapping(value = "/getGroupTeachingClassAndSchedule")
    @LogAnnotation(operationType = "3", operationContent = "获取分组教学班课表")
    public ResponseObject<List<TeachingClassWeekScheduleDto>> getGroupTeachingClassAndSchedule(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                                               @ApiParam(value = "分组id", required = true) @RequestParam String uniqueGroupSign,
                                                                                               @ApiParam(value = "分组名称", required = true) @RequestParam String groupName) {
        return ResponseObject.ofSuccess(scheduleService.getGroupTeachingClassAndSchedule(taskId, uniqueGroupSign, groupName));
    }

    @ApiOperation("获取待排教学班课表")
    @GetMapping(value = "/unRange/schedule")
    public ResponseObject<List<ViewScheduleDto>> getUnRangeSchedule(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                    @ApiParam(value = "教学班id", required = true) @RequestParam Long teachingClassId) {
        return ResponseObject.ofSuccess(scheduleService.getUnRangeSchedule(taskId, teachingClassId));
    }

    @ApiOperation("获取待排分组教学班课表")
    @GetMapping(value = "/unRange/groupSchedule")
    public ResponseObject<List<GroupViewSchedule>> getGroupUnRangeSchedule(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                           @ApiParam(value = "分组id", required = true) @RequestParam String subId,
                                                                           @ApiParam(value = "分组名称", required = false) @RequestParam(required = false) String subName) {
        return ResponseObject.ofSuccess(scheduleService.getGroupUnRangeSchedule(taskId, subId, subName));
    }

    @ApiOperation("获取全部教师 根据课题组分组")
    @GetMapping(value = "/getTeacherTree")
    @LogAnnotation(operationType = "3", operationContent = "获取全部教师 根据课题组分组")
    public ResponseObject<List<TeacherGroupTree>> getTeacherTree(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                 @ApiParam(value = "学校Id", required = true) @RequestParam String schoolId,
                                                                 @ApiParam(value = "学期", required = true) @RequestParam String term,
                                                                 @ApiParam(value = "module 1：排课状态 2：不要排课状态", required = true) @RequestParam Integer module,
                                                                 @ApiParam(value = "baseCollegeId", required = false) @RequestParam(required = false) String baseCollegeId,
                                                                 @ApiParam(value = "keyword", required = false) @RequestParam(required = false) String keyword) {
        return ResponseObject.ofSuccess(teacherService.getTeacherTree(taskId, schoolId, term, baseCollegeId, module, keyword));
    }

    @ApiOperation("获取教师待排教学班")
    @GetMapping(value = "/teacher/unRange")
    public ResponseObject<List<TeachingClassWeekScheduleDto>> getTeacherUnRange(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                                @ApiParam(value = "院系id", required = false) @RequestParam(required = false) String collegeId,
                                                                                @ApiParam(value = "keyword", required = false) @RequestParam(required = false) String keyword,
                                                                                @ApiParam(value = "教师id", required = true) @RequestParam Long teacherId) {
        return ResponseObject.ofSuccess(scheduleService.getTeacherUnRange(taskId, collegeId, teacherId, keyword));
    }

    @ApiOperation("获取教师待排教学班课表")
    @GetMapping(value = "/teacher/unRange/schedule")
    public ResponseObject<List<ViewScheduleDto>> getTeacherUnRangeSchedule(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                           @ApiParam(value = "教师id", required = true) @RequestParam Long teacherId,
                                                                           @ApiParam(value = "教学班id", required = true) @RequestParam Long teachingClassId) {
        return ResponseObject.ofSuccess(scheduleService.getTeacherUnRangeSchedule(taskId, teacherId, teachingClassId));
    }

    @ApiOperation("获取教室树")
    @GetMapping(value = "/getRoomTree")
    @LogAnnotation(operationType = "3", operationContent = "获取全部教师 根据课题组分组")
    public ResponseObject<List<RoomCollegeTreeVo>> getRoomTree(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                               @ApiParam(value = "学校Id", required = true) @RequestParam String schoolId,
                                                               @ApiParam(value = "学期", required = true) @RequestParam String term,
                                                               @ApiParam(value = "module 1：排课状态 2：不要排课状态", required = true) @RequestParam Integer module,
                                                               @ApiParam(value = "baseCollegeId", required = false) @RequestHeader(required = false) String baseCollegeId,
                                                               @ApiParam(value = "keyword", required = false) @RequestParam(required = false) String keyword) {
        return ResponseObject.ofSuccess(roomService.getRoomCollegeTree(taskId, schoolId, term, baseCollegeId, module, keyword));
    }

    @ApiOperation("获取教室待排教学班")
    @GetMapping(value = "/room/unRange")
    public ResponseObject<List<TeachingClassWeekScheduleDto>> getRoomUnRange(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                             @ApiParam(value = "院系id", required = false) @RequestParam(required = false) String collegeId,
                                                                             @ApiParam(value = "keyword", required = false) @RequestParam(required = false) String keyword,
                                                                             @ApiParam(value = "教师id", required = true) @RequestParam Long roomId) {
        return ResponseObject.ofSuccess(scheduleService.getRoomUnRange(taskId, collegeId, roomId, keyword));
    }

    @ApiOperation("获取教室待排教学班课表")
    @GetMapping(value = "/room/unRange/schedule")
    public ResponseObject<List<ViewScheduleDto>> getRoomUnRangeSchedule(@ApiParam(value = "任务流程id", required = true) @RequestHeader Integer taskId,
                                                                        @ApiParam(value = "教室id", required = true) @RequestParam Long roomId,
                                                                        @ApiParam(value = "教学班id", required = true) @RequestParam Long teachingClassId) {
        return ResponseObject.ofSuccess(scheduleService.getRoomUnRangeSchedule(taskId, roomId, teachingClassId));
    }

}
